home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TOptRelax.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  3.6 KB  |  95 lines  |  [TEXT/MPS ]

  1. #pragma segment MenuOption
  2. //*********************************************************************************
  3. //    TRelax - Methods
  4. //        inherits all methods and vars from TDialogView
  5. //        overrides method : DoChoice
  6. //*********************************************************************************
  7. //    fRelax    [0]    =    u
  8. //                [1]    =    v
  9. //                [2]    =    pressure
  10. //                [3]    =    w
  11. //                [4]    =    kinetic energy & dissipation
  12. //                [5]    =    density
  13. //                [6]    =    h, f, fu, & g
  14. //------------------------------------------------------------------------------------------
  15. //    TOptFlow DoChoice Method... Implementation
  16. //------------------------------------------------------------------------------------------
  17. pascal void TRelax::DoChoice(TView *origView, short itsChoice)
  18.     {
  19.     TWindow        * aWindow;
  20.     short             index;
  21.     
  22.     aWindow = this->GetWindow();                                                                // window containing this object
  23.     
  24.     switch (itsChoice)
  25.         {
  26.         case mVScrollBarHit :                                                                        // change a scroll bar?
  27.             float itsValue;                                                                                // the coord of the scroller
  28.             for (index = 1; index < 8; index++)                                                // cycle through all scrollers
  29.                 {
  30.                 this->GetControlName(index,"SC");                                            // get scroller name
  31.                 if (origView == (TScrollBar *) aWindow->FindSubView(tbox.boxID)) // get the scroll bar object
  32.                     {
  33.                     itsValue = (float) ((TScrollBar *) origView)->fLongVal;            // scroller value
  34.                     itsValue =  1 - (itsValue / 10);
  35.                     this->DisplayValue(index,itsValue);
  36.                     ((TCFDFrontDocument *) fDocument)->SetRelaxOpts(index,itsValue); // store the data
  37.                     break;
  38.                     }
  39.                 }
  40.             break;
  41.         }
  42.     inherited::DoChoice(origView,itsChoice);
  43.     }
  44.  
  45. //------------------------------------------------------------------------------------------
  46. //    Dismiss the Dialog
  47. //------------------------------------------------------------------------------------------
  48. pascal void TRelax::DismissDialog(ResType dismisser)
  49.     {
  50.     ((TCFDFrontDocument *) fDocument)->SetDialogOn(false,cRelaxDialog);
  51.     inherited::DismissDialog(dismisser);
  52.     }
  53.  
  54. //------------------------------------------------------------------------------------------
  55. //    Decode the print options long int
  56. //------------------------------------------------------------------------------------------
  57. void TRelax::MarkScroller (float * scroller)
  58.     {
  59.     TWindow         *    aWindow;
  60.     TScrollBar     *    bar;
  61.     short index;
  62.     long     value;
  63.     
  64.     aWindow = this->GetWindow();                                                    // get reference to the window
  65.  
  66.     for (index = 1; index < 8; index++)                                            // do all scrollers
  67.         {
  68.         this->GetControlName(index,"SC");                                        // puts scroller name in tbox    
  69.         bar = (TScrollBar *) aWindow->FindSubView(tbox.boxID);        // get pointer to the box
  70.         value = (long) (scroller[index-1] * 10);
  71.         value = 10 - value;
  72.         bar->SetLongVal(value,true);                                                // set new value & redraw
  73.         this->DisplayValue(index,scroller[index-1]);                        // set the static display boxes
  74.         }
  75.     return;
  76.     }
  77.  
  78. //------------------------------------------------------------------------------------------
  79. //    Display the value associated to the scroll bar
  80. //------------------------------------------------------------------------------------------
  81. void TRelax::DisplayValue (short index, float value)
  82.     {
  83.     TWindow        * aWindow;
  84.     TStaticText    * theText;
  85.     StringPtr        pText;
  86.     char             strng[10];
  87.     
  88.     aWindow = this->GetWindow();                                                    // window containing this object
  89.     this->GetControlName(index,"SB");                                            // get associated text field name
  90.     theText = (TStaticText *) aWindow->FindSubView(tbox.boxID); // get  associated text name
  91.     sprintf(strng,"%2.1f",value);                                                    // create a string
  92.     pText = c2pstr(strng);                                                                // convert to pascal
  93.     theText->SetText(pText,kRedraw);                                            // display the value
  94.     
  95.     }